package behavioral.command.base;

import behavioral.command.base.cmds.NoCmd;

/**
 * 控制器-遥控
 */
public class Cotroler {
    Command[] onCmds;
    Command[] offCmds;

    public Cotroler() {
        onCmds = new Command[5];
        offCmds = new Command[5];
        Command cmd = new NoCmd();
        for (int i = 0; i < 5; i++) {
            onCmds[i] = cmd;
            offCmds[i] = cmd;
        }
    }

    public void setCommand(int slot, Command onCommand, Command offCommand) {
        onCmds[slot] = onCommand;
        offCmds[slot] = offCommand;
    }

    public void onBtnClick(int solt) {
        onCmds[solt].execute();
    }

    public void offBtnClick(int solt) {
        offCmds[solt].execute();
    }
}
